{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "26bb937f",
   "metadata": {},
   "source": [
    "# 导入模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 198,
   "id": "3bc3846c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pyecharts.charts import Map\n",
    "from pyecharts.charts import Bar\n",
    "from pyecharts.charts import Line\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Pie\n",
    "from pyecharts.commons.utils import JsCode"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 199,
   "id": "b9ed9fb7",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Map, EffectScatter, HeatMap, Line,Grid,Geo\n",
    "from pyecharts.faker import Faker\n",
    "from pyecharts.globals import SymbolType\n",
    "from pyecharts.charts import Pie,Bar,Pie,WordCloud\n",
    "import random\n",
    "from calendar import c\n",
    "from tkinter import Grid\n",
    "from pyecharts.commons.utils import JsCode\n",
    "import re\n",
    "import collections\n",
    "import jieba\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.components import Table\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.globals import ChartType\n",
    "import textwrap"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f76dbf09",
   "metadata": {},
   "source": [
    "# 老年人口"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d4a312de",
   "metadata": {},
   "source": [
    "## 广东省各市基本养老保险"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 200,
   "id": "8bc639e7",
   "metadata": {},
   "outputs": [],
   "source": [
    "### 地图（√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 201,
   "id": "f220ff7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>城市</th>\n",
       "      <th>基本养老保险(万元)</th>\n",
       "      <th>基金征缴率</th>\n",
       "      <th>失业保险(万元)</th>\n",
       "      <th>基金征缴率.1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>深圳市</td>\n",
       "      <td>5363531</td>\n",
       "      <td>99.853159</td>\n",
       "      <td>534106</td>\n",
       "      <td>99.427136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>广州市</td>\n",
       "      <td>3354970</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>275611</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中山市</td>\n",
       "      <td>834511</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>40166</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>珠海市</td>\n",
       "      <td>625518</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>52633</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>江门市</td>\n",
       "      <td>600201</td>\n",
       "      <td>98.431210</td>\n",
       "      <td>29839</td>\n",
       "      <td>99.079428</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>惠州市</td>\n",
       "      <td>531906</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>19283</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>汕头市</td>\n",
       "      <td>328519</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>26686</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>湛江市</td>\n",
       "      <td>317597</td>\n",
       "      <td>97.886560</td>\n",
       "      <td>16488</td>\n",
       "      <td>99.035253</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>茂名市</td>\n",
       "      <td>261929</td>\n",
       "      <td>96.001056</td>\n",
       "      <td>17367</td>\n",
       "      <td>98.302029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>肇庆市</td>\n",
       "      <td>252590</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>17369</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>清远市</td>\n",
       "      <td>249045</td>\n",
       "      <td>99.962670</td>\n",
       "      <td>15990</td>\n",
       "      <td>99.993659</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>韶关市</td>\n",
       "      <td>238925</td>\n",
       "      <td>97.160915</td>\n",
       "      <td>14781</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>梅州市</td>\n",
       "      <td>235298</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>9439</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>揭阳市</td>\n",
       "      <td>212710</td>\n",
       "      <td>82.091349</td>\n",
       "      <td>4883</td>\n",
       "      <td>99.957806</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>汕尾市</td>\n",
       "      <td>98282</td>\n",
       "      <td>57.878662</td>\n",
       "      <td>4953</td>\n",
       "      <td>77.438137</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     城市  基本养老保险(万元)       基金征缴率  失业保险(万元)     基金征缴率.1\n",
       "0   深圳市     5363531   99.853159    534106   99.427136\n",
       "1   广州市     3354970  100.000000    275611  100.000000\n",
       "2   中山市      834511  100.000000     40166  100.000000\n",
       "3   珠海市      625518  100.000000     52633  100.000000\n",
       "4   江门市      600201   98.431210     29839   99.079428\n",
       "5   惠州市      531906  100.000000     19283  100.000000\n",
       "6   汕头市      328519  100.000000     26686  100.000000\n",
       "7   湛江市      317597   97.886560     16488   99.035253\n",
       "8   茂名市      261929   96.001056     17367   98.302029\n",
       "9   肇庆市      252590  100.000000     17369  100.000000\n",
       "10  清远市      249045   99.962670     15990   99.993659\n",
       "11  韶关市      238925   97.160915     14781  100.000000\n",
       "12  梅州市      235298  100.000000      9439  100.000000\n",
       "13  揭阳市      212710   82.091349      4883   99.957806\n",
       "14  汕尾市       98282   57.878662      4953   77.438137"
      ]
     },
     "execution_count": 201,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "guangdong=pd.read_excel('data/广东省各市社会基本养老.xlsx',sheet_name='广东省各市社会基本养老')\n",
    "guangdong"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 202,
   "id": "58e57e6a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'C:/python/pyecharts-assets-master/assets/echarts.min', '广东':'C:/python/pyecharts-assets-master/assets/maps/guangdong'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"0df48910230c444cbdc611a077cf891b\" style=\"width:1200px; height:600px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', '广东'], function(echarts) {\n",
       "                var chart_0df48910230c444cbdc611a077cf891b = echarts.init(\n",
       "                    document.getElementById('0df48910230c444cbdc611a077cf891b'), 'white', {renderer: 'canvas'});\n",
       "                var option_0df48910230c444cbdc611a077cf891b = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"name\": \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u57fa\\u672c\\u517b\\u8001\\u4fdd\\u9669\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"\\u5e7f\\u4e1c\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u6df1\\u5733\\u5e02\",\n",
       "                    \"value\": 5363531\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u5dde\\u5e02\",\n",
       "                    \"value\": 3354970\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e2d\\u5c71\\u5e02\",\n",
       "                    \"value\": 834511\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u73e0\\u6d77\\u5e02\",\n",
       "                    \"value\": 625518\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u95e8\\u5e02\",\n",
       "                    \"value\": 600201\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u60e0\\u5dde\\u5e02\",\n",
       "                    \"value\": 531906\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c55\\u5934\\u5e02\",\n",
       "                    \"value\": 328519\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e5b\\u6c5f\\u5e02\",\n",
       "                    \"value\": 317597\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8302\\u540d\\u5e02\",\n",
       "                    \"value\": 261929\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8087\\u5e86\\u5e02\",\n",
       "                    \"value\": 252590\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e05\\u8fdc\\u5e02\",\n",
       "                    \"value\": 249045\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u97f6\\u5173\\u5e02\",\n",
       "                    \"value\": 238925\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6885\\u5dde\\u5e02\",\n",
       "                    \"value\": 235298\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u63ed\\u9633\\u5e02\",\n",
       "                    \"value\": 212710\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c55\\u5c3e\\u5e02\",\n",
       "                    \"value\": 98282\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": true,\n",
       "            \"emphasis\": {},\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u57fa\\u672c\\u517b\\u8001\\u4fdd\\u9669\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u57fa\\u672c\\u517b\\u8001\\u4fdd\\u9669\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u57fa\\u672c\\u517b\\u8001\\u4fdd\\u9669\",\n",
       "            \"subtext\": \"\\u6570\\u636e\\u6765\\u6e90\\uff1a\\u5e7f\\u4e1c\\u7edf\\u8ba1\\u5e74\\u9274\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"piecewise\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 5363531,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"lightskyblue\",\n",
       "                \"yellow\",\n",
       "                \"orangered\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 14,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_0df48910230c444cbdc611a077cf891b.setOption(option_0df48910230c444cbdc611a077cf891b);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27086419670>"
      ]
     },
     "execution_count": 202,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "map=Map(init_opts=opts.InitOpts(width=\"1200px\",height='600px'))\n",
    "map.add('广东省各市基本养老保险',data_pair=z3,maptype='广东',is_map_symbol_show=True)\n",
    "map.set_series_opts(label_opts=opts.LabelOpts(is_show=True))\n",
    "map.set_global_opts(title_opts=opts.TitleOpts(title='广东省各市基本养老保险',subtitle='数据来源：广东统计年鉴'),\n",
    "    visualmap_opts=opts.VisualMapOpts(max_=5363531,is_piecewise=True,range_color=['lightskyblue','yellow','orangered']))\n",
    "map.render_notebook()\n",
    "# map.render('html/广东省地图.html') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 203,
   "id": "7302c85e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'C:/python/pyecharts-assets-master/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"a66488b6951345d7ac304f54874c0405\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_a66488b6951345d7ac304f54874c0405 = echarts.init(\n",
       "                    document.getElementById('a66488b6951345d7ac304f54874c0405'), 'white', {renderer: 'canvas'});\n",
       "                var option_a66488b6951345d7ac304f54874c0405 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5730\\u5e02\\u5931\\u4e1a\\u4fdd\\u9669\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                534106,\n",
       "                275611,\n",
       "                40166,\n",
       "                52633,\n",
       "                29839,\n",
       "                19283,\n",
       "                26686,\n",
       "                16488,\n",
       "                17367,\n",
       "                17369,\n",
       "                15990,\n",
       "                14781,\n",
       "                9439,\n",
       "                4883,\n",
       "                4953\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5730\\u5e02\\u5931\\u4e1a\\u4fdd\\u9669\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5730\\u5e02\\u5931\\u4e1a\\u4fdd\\u9669\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u6df1\\u5733\\u5e02\",\n",
       "                \"\\u5e7f\\u5dde\\u5e02\",\n",
       "                \"\\u4e2d\\u5c71\\u5e02\",\n",
       "                \"\\u73e0\\u6d77\\u5e02\",\n",
       "                \"\\u6c5f\\u95e8\\u5e02\",\n",
       "                \"\\u60e0\\u5dde\\u5e02\",\n",
       "                \"\\u6c55\\u5934\\u5e02\",\n",
       "                \"\\u6e5b\\u6c5f\\u5e02\",\n",
       "                \"\\u8302\\u540d\\u5e02\",\n",
       "                \"\\u8087\\u5e86\\u5e02\",\n",
       "                \"\\u6e05\\u8fdc\\u5e02\",\n",
       "                \"\\u97f6\\u5173\\u5e02\",\n",
       "                \"\\u6885\\u5dde\\u5e02\",\n",
       "                \"\\u63ed\\u9633\\u5e02\",\n",
       "                \"\\u6c55\\u5c3e\\u5e02\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5730\\u5e02\\u5931\\u4e1a\\u4fdd\\u9669\",\n",
       "            \"subtext\": \"\\u8fd9\\u662f\\u5e7f\\u4e1c\\u7701\\u4e0d\\u540c\\u57ce\\u5e02\\u7684\\u5931\\u4e1a\\u4fdd\\u9669\\uff0c\\u4ece\\u4e2d\\u6211\\u4eec\\u53ef\\u4ee5\\u770b\\u5230\\u4e5f\\u5c31\\u662f\\u5c71\\u4e1c\\u7701\\u7684\\u8001\\u5e74\\u4eba\\u53e3\\u6570\\u91cf\\u6700\\u591a\",\n",
       "            \"top\": \"0\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_a66488b6951345d7ac304f54874c0405.setOption(option_a66488b6951345d7ac304f54874c0405);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27086652af0>"
      ]
     },
     "execution_count": 203,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Bar\n",
    "#xy轴数据\n",
    "x= guangdong['城市']\n",
    "x1=list(x)\n",
    "\n",
    "y=guangdong['失业保险(万元)']\n",
    "y1=list(y)\n",
    "\n",
    "#柱形图\n",
    "l1=x1\n",
    "l2=y1\n",
    "bar = (\n",
    "    Bar()\n",
    "    .add_xaxis(l1)\n",
    "    .add_yaxis(\"广东省各地市失业保险\", l2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"广东省各地市失业保险\",\n",
    "                                                subtitle=\"这是广东省不同城市的失业保险，从中我们可以看到也就是山东省的老年人口数量最多\",\n",
    "                                                pos_top=\"0\", ),\n",
    "                     datazoom_opts=opts.DataZoomOpts(type_=\"slider\"))\n",
    ")\n",
    "bar.render_notebook()\n",
    "# bar.render('不同行业公司数量图.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4cc617f8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f7987f92",
   "metadata": {},
   "source": [
    "### 堆叠图（√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 204,
   "id": "492acace",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>城市</th>\n",
       "      <th>基本养老保险(万元)</th>\n",
       "      <th>基金征缴率</th>\n",
       "      <th>失业保险(万元)</th>\n",
       "      <th>基金征缴率.1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>深圳市</td>\n",
       "      <td>5363531</td>\n",
       "      <td>99.853159</td>\n",
       "      <td>534106</td>\n",
       "      <td>99.427136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>广州市</td>\n",
       "      <td>3354970</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>275611</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中山市</td>\n",
       "      <td>834511</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>40166</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>珠海市</td>\n",
       "      <td>625518</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>52633</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>江门市</td>\n",
       "      <td>600201</td>\n",
       "      <td>98.431210</td>\n",
       "      <td>29839</td>\n",
       "      <td>99.079428</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>惠州市</td>\n",
       "      <td>531906</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>19283</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>汕头市</td>\n",
       "      <td>328519</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>26686</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>湛江市</td>\n",
       "      <td>317597</td>\n",
       "      <td>97.886560</td>\n",
       "      <td>16488</td>\n",
       "      <td>99.035253</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>茂名市</td>\n",
       "      <td>261929</td>\n",
       "      <td>96.001056</td>\n",
       "      <td>17367</td>\n",
       "      <td>98.302029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>肇庆市</td>\n",
       "      <td>252590</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>17369</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>清远市</td>\n",
       "      <td>249045</td>\n",
       "      <td>99.962670</td>\n",
       "      <td>15990</td>\n",
       "      <td>99.993659</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>韶关市</td>\n",
       "      <td>238925</td>\n",
       "      <td>97.160915</td>\n",
       "      <td>14781</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>梅州市</td>\n",
       "      <td>235298</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>9439</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>揭阳市</td>\n",
       "      <td>212710</td>\n",
       "      <td>82.091349</td>\n",
       "      <td>4883</td>\n",
       "      <td>99.957806</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>汕尾市</td>\n",
       "      <td>98282</td>\n",
       "      <td>57.878662</td>\n",
       "      <td>4953</td>\n",
       "      <td>77.438137</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     城市  基本养老保险(万元)       基金征缴率  失业保险(万元)     基金征缴率.1\n",
       "0   深圳市     5363531   99.853159    534106   99.427136\n",
       "1   广州市     3354970  100.000000    275611  100.000000\n",
       "2   中山市      834511  100.000000     40166  100.000000\n",
       "3   珠海市      625518  100.000000     52633  100.000000\n",
       "4   江门市      600201   98.431210     29839   99.079428\n",
       "5   惠州市      531906  100.000000     19283  100.000000\n",
       "6   汕头市      328519  100.000000     26686  100.000000\n",
       "7   湛江市      317597   97.886560     16488   99.035253\n",
       "8   茂名市      261929   96.001056     17367   98.302029\n",
       "9   肇庆市      252590  100.000000     17369  100.000000\n",
       "10  清远市      249045   99.962670     15990   99.993659\n",
       "11  韶关市      238925   97.160915     14781  100.000000\n",
       "12  梅州市      235298  100.000000      9439  100.000000\n",
       "13  揭阳市      212710   82.091349      4883   99.957806\n",
       "14  汕尾市       98282   57.878662      4953   77.438137"
      ]
     },
     "execution_count": 204,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "guangdong=pd.read_excel('data/广东省各市社会基本养老.xlsx',sheet_name='广东省各市社会基本养老'\n",
    "                     )\n",
    "guangdong"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 205,
   "id": "e9b54fee",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'城市'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32mD:\\anaconda\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m   3079\u001b[0m             \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3080\u001b[1;33m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3081\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: '城市'",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-205-0ea31bcdaf7b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m stack_bar = (\n\u001b[0;32m      2\u001b[0m     \u001b[0mBar\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minit_opts\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mopts\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mInitOpts\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mwidth\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"900px\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mheight\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"600px\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m     \u001b[1;33m.\u001b[0m\u001b[0madd_xaxis\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0myuangong\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"城市\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtolist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      4\u001b[0m     \u001b[1;33m.\u001b[0m\u001b[0madd_yaxis\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"基本养老保险(万元)\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0myuangong\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"基金征缴率\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtolist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstack\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"stack1\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcolor\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"Turquoise\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m     \u001b[1;33m.\u001b[0m\u001b[0madd_yaxis\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"失业保险(万元)\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0myuangong\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"基金征缴率.1\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtolist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstack\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"stack1\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mcolor\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"DarkCyan\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\anaconda\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m   3022\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlevels\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3023\u001b[0m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3024\u001b[1;33m             \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3025\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3026\u001b[0m                 \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\anaconda\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m   3080\u001b[0m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3081\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3082\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3083\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3084\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mtolerance\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: '城市'"
     ]
    }
   ],
   "source": [
    "stack_bar = (\n",
    "    Bar(init_opts=opts.InitOpts(width=\"900px\", height=\"600px\"))\n",
    "    .add_xaxis(yuangong[\"城市\"].tolist())\n",
    "    .add_yaxis(\"基本养老保险(万元)\", yuangong[\"基金征缴率\"].tolist(), stack=\"stack1\", color=\"Turquoise\")\n",
    "    .add_yaxis(\"失业保险(万元)\", yuangong[\"基金征缴率.1\"].tolist(), stack=\"stack1\",color=\"DarkCyan\")\n",
    "     .set_global_opts(title_opts=opts.TitleOpts(title=\"养老从业人员（单位：%）\"),\n",
    "                     datazoom_opts=opts.DataZoomOpts(type_=\"slider\"))\n",
    "    # 在系列设置中设置标签属性\n",
    "    .set_series_opts(\n",
    "        label_opts=opts.LabelOpts(position=\"inside\", color=\"white\", font_size=10)\n",
    "    )\n",
    ")\n",
    "\n",
    "stack_bar.render_notebook()\n",
    "# stack_bar.render('html/养老从业人员.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 206,
   "id": "a80bc2ca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'C:/python/pyecharts-assets-master/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"11b313786d5d45f0ab3762fdb9f6e7fe\" style=\"width:1000px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_11b313786d5d45f0ab3762fdb9f6e7fe = echarts.init(\n",
       "                    document.getElementById('11b313786d5d45f0ab3762fdb9f6e7fe'), 'white', {renderer: 'canvas'});\n",
       "                var option_11b313786d5d45f0ab3762fdb9f6e7fe = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"funnel\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u6df1\\u5733\\u5e02\",\n",
       "                    \"value\": 534106\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u5dde\\u5e02\",\n",
       "                    \"value\": 275611\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e2d\\u5c71\\u5e02\",\n",
       "                    \"value\": 40166\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u73e0\\u6d77\\u5e02\",\n",
       "                    \"value\": 52633\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u95e8\\u5e02\",\n",
       "                    \"value\": 29839\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u60e0\\u5dde\\u5e02\",\n",
       "                    \"value\": 19283\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c55\\u5934\\u5e02\",\n",
       "                    \"value\": 26686\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e5b\\u6c5f\\u5e02\",\n",
       "                    \"value\": 16488\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8302\\u540d\\u5e02\",\n",
       "                    \"value\": 17367\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8087\\u5e86\\u5e02\",\n",
       "                    \"value\": 17369\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e05\\u8fdc\\u5e02\",\n",
       "                    \"value\": 15990\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u97f6\\u5173\\u5e02\",\n",
       "                    \"value\": 14781\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6885\\u5dde\\u5e02\",\n",
       "                    \"value\": 9439\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u63ed\\u9633\\u5e02\",\n",
       "                    \"value\": 4883\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c55\\u5c3e\\u5e02\",\n",
       "                    \"value\": 4953\n",
       "                }\n",
       "            ],\n",
       "            \"sort\": \"descending\",\n",
       "            \"gap\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"inside\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"formatter\": \"{a} <br/>{b} : {c}%\",\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"itemStyle\": {\n",
       "                \"borderColor\": \"#fff\",\n",
       "                \"borderWidth\": 1\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8087\\u5e86\\u5e02\",\n",
       "                \"\\u4e2d\\u5c71\\u5e02\",\n",
       "                \"\\u6c5f\\u95e8\\u5e02\",\n",
       "                \"\\u63ed\\u9633\\u5e02\",\n",
       "                \"\\u73e0\\u6d77\\u5e02\",\n",
       "                \"\\u8302\\u540d\\u5e02\",\n",
       "                \"\\u6e5b\\u6c5f\\u5e02\",\n",
       "                \"\\u6e05\\u8fdc\\u5e02\",\n",
       "                \"\\u6df1\\u5733\\u5e02\",\n",
       "                \"\\u97f6\\u5173\\u5e02\",\n",
       "                \"\\u5e7f\\u5dde\\u5e02\",\n",
       "                \"\\u6c55\\u5934\\u5e02\",\n",
       "                \"\\u60e0\\u5dde\\u5e02\",\n",
       "                \"\\u6c55\\u5c3e\\u5e02\",\n",
       "                \"\\u6885\\u5dde\\u5e02\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u6df1\\u5733\\u5e02\": true,\n",
       "                \"\\u5e7f\\u5dde\\u5e02\": true,\n",
       "                \"\\u4e2d\\u5c71\\u5e02\": true,\n",
       "                \"\\u73e0\\u6d77\\u5e02\": true,\n",
       "                \"\\u6c5f\\u95e8\\u5e02\": true,\n",
       "                \"\\u60e0\\u5dde\\u5e02\": true,\n",
       "                \"\\u6c55\\u5934\\u5e02\": true,\n",
       "                \"\\u6e5b\\u6c5f\\u5e02\": true,\n",
       "                \"\\u8302\\u540d\\u5e02\": true,\n",
       "                \"\\u8087\\u5e86\\u5e02\": true,\n",
       "                \"\\u6e05\\u8fdc\\u5e02\": true,\n",
       "                \"\\u97f6\\u5173\\u5e02\": true,\n",
       "                \"\\u6885\\u5dde\\u5e02\": true,\n",
       "                \"\\u63ed\\u9633\\u5e02\": true,\n",
       "                \"\\u6c55\\u5c3e\\u5e02\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6f0f\\u6597\\u56fe\",\n",
       "            \"subtext\": \"\\u7eaf\\u5c5e\\u865a\\u6784\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_11b313786d5d45f0ab3762fdb9f6e7fe.setOption(option_11b313786d5d45f0ab3762fdb9f6e7fe);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27086414dc0>"
      ]
     },
     "execution_count": 206,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Funnel\n",
    "#xy轴数据\n",
    "x= guangdong['城市']\n",
    "x1=list(x)\n",
    "\n",
    "y= guangdong['失业保险(万元)']\n",
    "y1=list(y)\n",
    "# x_data = [\"展现\", \"点击\", \"访问\", \"咨询\", \"订单\"]\n",
    "# y_data = [100, 80, 60, 40, 20]\n",
    "\n",
    "data = [[x1[i], y1[i]] for i in range(len(x1))]\n",
    "\n",
    "(\n",
    "    Funnel(init_opts=opts.InitOpts(width=\"1000px\", height=\"500px\"))\n",
    "    .add(\n",
    "        series_name=\"\",\n",
    "        data_pair=data,\n",
    "        gap=2,\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"item\", formatter=\"{a} <br/>{b} : {c}%\"),\n",
    "        label_opts=opts.LabelOpts(is_show=True, position=\"inside\"),\n",
    "        itemstyle_opts=opts.ItemStyleOpts(border_color=\"#fff\", border_width=1),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"漏斗图\", subtitle=\"纯属虚构\"))\n",
    "#     .render(\"funnel_chart.html\")\n",
    "   .render_notebook()\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 207,
   "id": "e21babc5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'C:/python/pyecharts-assets-master/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"64747daf38fa46e19bcb347054fe1693\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_64747daf38fa46e19bcb347054fe1693 = echarts.init(\n",
       "                    document.getElementById('64747daf38fa46e19bcb347054fe1693'), 'white', {renderer: 'canvas'});\n",
       "                var option_64747daf38fa46e19bcb347054fe1693 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u6df1\\u5733\\u5e02\",\n",
       "                    \"value\": 5363531\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u5dde\\u5e02\",\n",
       "                    \"value\": 3354970\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e2d\\u5c71\\u5e02\",\n",
       "                    \"value\": 834511\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u73e0\\u6d77\\u5e02\",\n",
       "                    \"value\": 625518\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u95e8\\u5e02\",\n",
       "                    \"value\": 600201\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u60e0\\u5dde\\u5e02\",\n",
       "                    \"value\": 531906\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c55\\u5934\\u5e02\",\n",
       "                    \"value\": 328519\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e5b\\u6c5f\\u5e02\",\n",
       "                    \"value\": 317597\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8302\\u540d\\u5e02\",\n",
       "                    \"value\": 261929\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8087\\u5e86\\u5e02\",\n",
       "                    \"value\": 252590\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e05\\u8fdc\\u5e02\",\n",
       "                    \"value\": 249045\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u97f6\\u5173\\u5e02\",\n",
       "                    \"value\": 238925\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6885\\u5dde\\u5e02\",\n",
       "                    \"value\": 235298\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u63ed\\u9633\\u5e02\",\n",
       "                    \"value\": 212710\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c55\\u5c3e\\u5e02\",\n",
       "                    \"value\": 98282\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c}\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u6df1\\u5733\\u5e02\",\n",
       "                \"\\u5e7f\\u5dde\\u5e02\",\n",
       "                \"\\u4e2d\\u5c71\\u5e02\",\n",
       "                \"\\u73e0\\u6d77\\u5e02\",\n",
       "                \"\\u6c5f\\u95e8\\u5e02\",\n",
       "                \"\\u60e0\\u5dde\\u5e02\",\n",
       "                \"\\u6c55\\u5934\\u5e02\",\n",
       "                \"\\u6e5b\\u6c5f\\u5e02\",\n",
       "                \"\\u8302\\u540d\\u5e02\",\n",
       "                \"\\u8087\\u5e86\\u5e02\",\n",
       "                \"\\u6e05\\u8fdc\\u5e02\",\n",
       "                \"\\u97f6\\u5173\\u5e02\",\n",
       "                \"\\u6885\\u5dde\\u5e02\",\n",
       "                \"\\u63ed\\u9633\\u5e02\",\n",
       "                \"\\u6c55\\u5c3e\\u5e02\"\n",
       "            ],\n",
       "            \"selected\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    }\n",
       "};\n",
       "                chart_64747daf38fa46e19bcb347054fe1693.setOption(option_64747daf38fa46e19bcb347054fe1693);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x2708682d4f0>"
      ]
     },
     "execution_count": 207,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x=guangdong[\"城市\"]\n",
    "x_data=list(x)\n",
    "y=guangdong[\"基本养老保险(万元)\"]\n",
    "y_data=list(y)\n",
    "c = (\n",
    "    Pie()\n",
    "    .add(\"\", [list(z) for z in zip(x_data, y_data)])   # zip函数两个部分组合在一起list(zip(x,y))-----> [(x,y)]\n",
    "#     .set_global_opts(title_opts=opts.TitleOpts(title=\"三大湾区总估值\"))  # 标题\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c}\"))  # 数据标签设置\n",
    ")\n",
    "\n",
    "c.render_notebook()\n",
    "# c.render('html/老龄人口比重.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a0a8fb0f",
   "metadata": {},
   "source": [
    "## 老年人口不同地区分布（全国）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 208,
   "id": "25586ecb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>地区</th>\n",
       "      <th>合计</th>\n",
       "      <th>男</th>\n",
       "      <th>女</th>\n",
       "      <th>健康小计</th>\n",
       "      <th>男（健康）</th>\n",
       "      <th>女（健康）</th>\n",
       "      <th>基本健康小计</th>\n",
       "      <th>男（基本健康）</th>\n",
       "      <th>女（基本健康）</th>\n",
       "      <th>不健康小计</th>\n",
       "      <th>男（不健康）</th>\n",
       "      <th>女（不健康）</th>\n",
       "      <th>不能自理小计</th>\n",
       "      <th>男（不能自理）</th>\n",
       "      <th>女（不能自理）</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>四    川</td>\n",
       "      <td>1412294</td>\n",
       "      <td>704476</td>\n",
       "      <td>707818</td>\n",
       "      <td>551709</td>\n",
       "      <td>303402</td>\n",
       "      <td>248307</td>\n",
       "      <td>592005</td>\n",
       "      <td>282438</td>\n",
       "      <td>309567</td>\n",
       "      <td>221883</td>\n",
       "      <td>99155</td>\n",
       "      <td>122728</td>\n",
       "      <td>46697</td>\n",
       "      <td>19481</td>\n",
       "      <td>27216</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>山    东</td>\n",
       "      <td>1400109</td>\n",
       "      <td>661388</td>\n",
       "      <td>738721</td>\n",
       "      <td>729311</td>\n",
       "      <td>378178</td>\n",
       "      <td>351133</td>\n",
       "      <td>462980</td>\n",
       "      <td>198008</td>\n",
       "      <td>264972</td>\n",
       "      <td>170304</td>\n",
       "      <td>70278</td>\n",
       "      <td>100026</td>\n",
       "      <td>37514</td>\n",
       "      <td>14924</td>\n",
       "      <td>22590</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>江    苏</td>\n",
       "      <td>1247962</td>\n",
       "      <td>598544</td>\n",
       "      <td>649418</td>\n",
       "      <td>626603</td>\n",
       "      <td>330740</td>\n",
       "      <td>295863</td>\n",
       "      <td>464007</td>\n",
       "      <td>202380</td>\n",
       "      <td>261627</td>\n",
       "      <td>127580</td>\n",
       "      <td>53329</td>\n",
       "      <td>74251</td>\n",
       "      <td>29772</td>\n",
       "      <td>12095</td>\n",
       "      <td>17677</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>河    南</td>\n",
       "      <td>1196924</td>\n",
       "      <td>569894</td>\n",
       "      <td>627030</td>\n",
       "      <td>567448</td>\n",
       "      <td>295386</td>\n",
       "      <td>272062</td>\n",
       "      <td>419979</td>\n",
       "      <td>187347</td>\n",
       "      <td>232632</td>\n",
       "      <td>171312</td>\n",
       "      <td>72514</td>\n",
       "      <td>98798</td>\n",
       "      <td>38185</td>\n",
       "      <td>14647</td>\n",
       "      <td>23538</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>广    东</td>\n",
       "      <td>957360</td>\n",
       "      <td>461728</td>\n",
       "      <td>495632</td>\n",
       "      <td>492653</td>\n",
       "      <td>255966</td>\n",
       "      <td>236687</td>\n",
       "      <td>366579</td>\n",
       "      <td>164524</td>\n",
       "      <td>202055</td>\n",
       "      <td>80918</td>\n",
       "      <td>34418</td>\n",
       "      <td>46500</td>\n",
       "      <td>17210</td>\n",
       "      <td>6820</td>\n",
       "      <td>10390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>湖    南</td>\n",
       "      <td>939818</td>\n",
       "      <td>469609</td>\n",
       "      <td>470209</td>\n",
       "      <td>330267</td>\n",
       "      <td>185827</td>\n",
       "      <td>144440</td>\n",
       "      <td>413669</td>\n",
       "      <td>197294</td>\n",
       "      <td>216375</td>\n",
       "      <td>167987</td>\n",
       "      <td>74863</td>\n",
       "      <td>93124</td>\n",
       "      <td>27895</td>\n",
       "      <td>11625</td>\n",
       "      <td>16270</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>河    北</td>\n",
       "      <td>928642</td>\n",
       "      <td>450063</td>\n",
       "      <td>478579</td>\n",
       "      <td>419065</td>\n",
       "      <td>223831</td>\n",
       "      <td>195234</td>\n",
       "      <td>341585</td>\n",
       "      <td>153799</td>\n",
       "      <td>187786</td>\n",
       "      <td>135863</td>\n",
       "      <td>58852</td>\n",
       "      <td>77011</td>\n",
       "      <td>32129</td>\n",
       "      <td>13581</td>\n",
       "      <td>18548</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>安    徽</td>\n",
       "      <td>853195</td>\n",
       "      <td>421912</td>\n",
       "      <td>431283</td>\n",
       "      <td>321509</td>\n",
       "      <td>181502</td>\n",
       "      <td>140007</td>\n",
       "      <td>354089</td>\n",
       "      <td>164907</td>\n",
       "      <td>189182</td>\n",
       "      <td>148715</td>\n",
       "      <td>64084</td>\n",
       "      <td>84631</td>\n",
       "      <td>28882</td>\n",
       "      <td>11419</td>\n",
       "      <td>17463</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>湖    北</td>\n",
       "      <td>779566</td>\n",
       "      <td>382160</td>\n",
       "      <td>397406</td>\n",
       "      <td>277089</td>\n",
       "      <td>153831</td>\n",
       "      <td>123258</td>\n",
       "      <td>347418</td>\n",
       "      <td>163091</td>\n",
       "      <td>184327</td>\n",
       "      <td>131477</td>\n",
       "      <td>55664</td>\n",
       "      <td>75813</td>\n",
       "      <td>23582</td>\n",
       "      <td>9574</td>\n",
       "      <td>14008</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>浙    江</td>\n",
       "      <td>759091</td>\n",
       "      <td>377570</td>\n",
       "      <td>381521</td>\n",
       "      <td>400645</td>\n",
       "      <td>215946</td>\n",
       "      <td>184699</td>\n",
       "      <td>266096</td>\n",
       "      <td>119703</td>\n",
       "      <td>146393</td>\n",
       "      <td>74373</td>\n",
       "      <td>34152</td>\n",
       "      <td>40221</td>\n",
       "      <td>17977</td>\n",
       "      <td>7769</td>\n",
       "      <td>10208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>辽    宁</td>\n",
       "      <td>672227</td>\n",
       "      <td>326082</td>\n",
       "      <td>346145</td>\n",
       "      <td>290920</td>\n",
       "      <td>156959</td>\n",
       "      <td>133961</td>\n",
       "      <td>270482</td>\n",
       "      <td>121123</td>\n",
       "      <td>149359</td>\n",
       "      <td>92374</td>\n",
       "      <td>39662</td>\n",
       "      <td>52712</td>\n",
       "      <td>18451</td>\n",
       "      <td>8338</td>\n",
       "      <td>10113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>广    西</td>\n",
       "      <td>616828</td>\n",
       "      <td>296065</td>\n",
       "      <td>320763</td>\n",
       "      <td>277551</td>\n",
       "      <td>145405</td>\n",
       "      <td>132146</td>\n",
       "      <td>243746</td>\n",
       "      <td>111190</td>\n",
       "      <td>132556</td>\n",
       "      <td>81266</td>\n",
       "      <td>33659</td>\n",
       "      <td>47607</td>\n",
       "      <td>14265</td>\n",
       "      <td>5811</td>\n",
       "      <td>8454</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>云    南</td>\n",
       "      <td>514563</td>\n",
       "      <td>247803</td>\n",
       "      <td>266760</td>\n",
       "      <td>219938</td>\n",
       "      <td>116480</td>\n",
       "      <td>103458</td>\n",
       "      <td>204988</td>\n",
       "      <td>93409</td>\n",
       "      <td>111579</td>\n",
       "      <td>69556</td>\n",
       "      <td>29771</td>\n",
       "      <td>39785</td>\n",
       "      <td>20081</td>\n",
       "      <td>8143</td>\n",
       "      <td>11938</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>江    西</td>\n",
       "      <td>504043</td>\n",
       "      <td>245931</td>\n",
       "      <td>258112</td>\n",
       "      <td>224487</td>\n",
       "      <td>122278</td>\n",
       "      <td>102209</td>\n",
       "      <td>206832</td>\n",
       "      <td>92353</td>\n",
       "      <td>114479</td>\n",
       "      <td>61859</td>\n",
       "      <td>26779</td>\n",
       "      <td>35080</td>\n",
       "      <td>10865</td>\n",
       "      <td>4521</td>\n",
       "      <td>6344</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>重    庆</td>\n",
       "      <td>488115</td>\n",
       "      <td>245856</td>\n",
       "      <td>242259</td>\n",
       "      <td>195759</td>\n",
       "      <td>107015</td>\n",
       "      <td>88744</td>\n",
       "      <td>201675</td>\n",
       "      <td>97514</td>\n",
       "      <td>104161</td>\n",
       "      <td>75456</td>\n",
       "      <td>34797</td>\n",
       "      <td>40659</td>\n",
       "      <td>15225</td>\n",
       "      <td>6530</td>\n",
       "      <td>8695</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>陕    西</td>\n",
       "      <td>487378</td>\n",
       "      <td>239095</td>\n",
       "      <td>248283</td>\n",
       "      <td>193803</td>\n",
       "      <td>104722</td>\n",
       "      <td>89081</td>\n",
       "      <td>202206</td>\n",
       "      <td>94348</td>\n",
       "      <td>107858</td>\n",
       "      <td>75574</td>\n",
       "      <td>33210</td>\n",
       "      <td>42364</td>\n",
       "      <td>15795</td>\n",
       "      <td>6815</td>\n",
       "      <td>8980</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>黑 龙 江</td>\n",
       "      <td>468616</td>\n",
       "      <td>229664</td>\n",
       "      <td>238952</td>\n",
       "      <td>199247</td>\n",
       "      <td>106452</td>\n",
       "      <td>92795</td>\n",
       "      <td>186754</td>\n",
       "      <td>85349</td>\n",
       "      <td>101405</td>\n",
       "      <td>70846</td>\n",
       "      <td>32242</td>\n",
       "      <td>38604</td>\n",
       "      <td>11769</td>\n",
       "      <td>5621</td>\n",
       "      <td>6148</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>贵    州</td>\n",
       "      <td>446686</td>\n",
       "      <td>217427</td>\n",
       "      <td>229259</td>\n",
       "      <td>189851</td>\n",
       "      <td>99935</td>\n",
       "      <td>89916</td>\n",
       "      <td>170481</td>\n",
       "      <td>79296</td>\n",
       "      <td>91185</td>\n",
       "      <td>71169</td>\n",
       "      <td>31448</td>\n",
       "      <td>39721</td>\n",
       "      <td>15185</td>\n",
       "      <td>6748</td>\n",
       "      <td>8437</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>福    建</td>\n",
       "      <td>420377</td>\n",
       "      <td>206976</td>\n",
       "      <td>213401</td>\n",
       "      <td>209198</td>\n",
       "      <td>111845</td>\n",
       "      <td>97353</td>\n",
       "      <td>163901</td>\n",
       "      <td>74194</td>\n",
       "      <td>89707</td>\n",
       "      <td>38889</td>\n",
       "      <td>17525</td>\n",
       "      <td>21364</td>\n",
       "      <td>8389</td>\n",
       "      <td>3412</td>\n",
       "      <td>4977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>山    西</td>\n",
       "      <td>414649</td>\n",
       "      <td>205903</td>\n",
       "      <td>208746</td>\n",
       "      <td>166386</td>\n",
       "      <td>92647</td>\n",
       "      <td>73739</td>\n",
       "      <td>165709</td>\n",
       "      <td>77211</td>\n",
       "      <td>88498</td>\n",
       "      <td>67164</td>\n",
       "      <td>29482</td>\n",
       "      <td>37682</td>\n",
       "      <td>15390</td>\n",
       "      <td>6563</td>\n",
       "      <td>8827</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>吉    林</td>\n",
       "      <td>349177</td>\n",
       "      <td>170725</td>\n",
       "      <td>178452</td>\n",
       "      <td>138085</td>\n",
       "      <td>75118</td>\n",
       "      <td>62967</td>\n",
       "      <td>144781</td>\n",
       "      <td>66330</td>\n",
       "      <td>78451</td>\n",
       "      <td>57155</td>\n",
       "      <td>24949</td>\n",
       "      <td>32206</td>\n",
       "      <td>9156</td>\n",
       "      <td>4328</td>\n",
       "      <td>4828</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>上    海</td>\n",
       "      <td>345592</td>\n",
       "      <td>165345</td>\n",
       "      <td>180247</td>\n",
       "      <td>150971</td>\n",
       "      <td>80339</td>\n",
       "      <td>70632</td>\n",
       "      <td>150631</td>\n",
       "      <td>67199</td>\n",
       "      <td>83432</td>\n",
       "      <td>31175</td>\n",
       "      <td>12607</td>\n",
       "      <td>18568</td>\n",
       "      <td>12815</td>\n",
       "      <td>5200</td>\n",
       "      <td>7615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>甘    肃</td>\n",
       "      <td>338325</td>\n",
       "      <td>168184</td>\n",
       "      <td>170141</td>\n",
       "      <td>118592</td>\n",
       "      <td>66042</td>\n",
       "      <td>52550</td>\n",
       "      <td>137527</td>\n",
       "      <td>65796</td>\n",
       "      <td>71731</td>\n",
       "      <td>70267</td>\n",
       "      <td>31297</td>\n",
       "      <td>38970</td>\n",
       "      <td>11939</td>\n",
       "      <td>5049</td>\n",
       "      <td>6890</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>内 蒙 古</td>\n",
       "      <td>275828</td>\n",
       "      <td>137565</td>\n",
       "      <td>138263</td>\n",
       "      <td>115534</td>\n",
       "      <td>63545</td>\n",
       "      <td>51989</td>\n",
       "      <td>105312</td>\n",
       "      <td>49682</td>\n",
       "      <td>55630</td>\n",
       "      <td>45236</td>\n",
       "      <td>19999</td>\n",
       "      <td>25237</td>\n",
       "      <td>9746</td>\n",
       "      <td>4339</td>\n",
       "      <td>5407</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>北    京</td>\n",
       "      <td>250084</td>\n",
       "      <td>118583</td>\n",
       "      <td>131501</td>\n",
       "      <td>99865</td>\n",
       "      <td>51709</td>\n",
       "      <td>48156</td>\n",
       "      <td>107068</td>\n",
       "      <td>48549</td>\n",
       "      <td>58519</td>\n",
       "      <td>32082</td>\n",
       "      <td>13652</td>\n",
       "      <td>18430</td>\n",
       "      <td>11069</td>\n",
       "      <td>4673</td>\n",
       "      <td>6396</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>新    疆</td>\n",
       "      <td>201515</td>\n",
       "      <td>101793</td>\n",
       "      <td>99722</td>\n",
       "      <td>72501</td>\n",
       "      <td>40531</td>\n",
       "      <td>31970</td>\n",
       "      <td>92420</td>\n",
       "      <td>44866</td>\n",
       "      <td>47554</td>\n",
       "      <td>30186</td>\n",
       "      <td>13575</td>\n",
       "      <td>16611</td>\n",
       "      <td>6408</td>\n",
       "      <td>2821</td>\n",
       "      <td>3587</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>天    津</td>\n",
       "      <td>162233</td>\n",
       "      <td>78029</td>\n",
       "      <td>84204</td>\n",
       "      <td>71973</td>\n",
       "      <td>37875</td>\n",
       "      <td>34098</td>\n",
       "      <td>67182</td>\n",
       "      <td>30285</td>\n",
       "      <td>36897</td>\n",
       "      <td>17195</td>\n",
       "      <td>7267</td>\n",
       "      <td>9928</td>\n",
       "      <td>5883</td>\n",
       "      <td>2602</td>\n",
       "      <td>3281</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>海    南</td>\n",
       "      <td>93525</td>\n",
       "      <td>44616</td>\n",
       "      <td>48909</td>\n",
       "      <td>37806</td>\n",
       "      <td>20174</td>\n",
       "      <td>17632</td>\n",
       "      <td>37809</td>\n",
       "      <td>17311</td>\n",
       "      <td>20498</td>\n",
       "      <td>15030</td>\n",
       "      <td>6041</td>\n",
       "      <td>8989</td>\n",
       "      <td>2880</td>\n",
       "      <td>1090</td>\n",
       "      <td>1790</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>宁    夏</td>\n",
       "      <td>61207</td>\n",
       "      <td>30331</td>\n",
       "      <td>30876</td>\n",
       "      <td>24491</td>\n",
       "      <td>13529</td>\n",
       "      <td>10962</td>\n",
       "      <td>25235</td>\n",
       "      <td>11892</td>\n",
       "      <td>13343</td>\n",
       "      <td>9462</td>\n",
       "      <td>4031</td>\n",
       "      <td>5431</td>\n",
       "      <td>2019</td>\n",
       "      <td>879</td>\n",
       "      <td>1140</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>青    海</td>\n",
       "      <td>51945</td>\n",
       "      <td>25059</td>\n",
       "      <td>26886</td>\n",
       "      <td>19806</td>\n",
       "      <td>10513</td>\n",
       "      <td>9293</td>\n",
       "      <td>21790</td>\n",
       "      <td>10238</td>\n",
       "      <td>11552</td>\n",
       "      <td>8436</td>\n",
       "      <td>3552</td>\n",
       "      <td>4884</td>\n",
       "      <td>1913</td>\n",
       "      <td>756</td>\n",
       "      <td>1157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>西    藏</td>\n",
       "      <td>20828</td>\n",
       "      <td>9304</td>\n",
       "      <td>11524</td>\n",
       "      <td>5110</td>\n",
       "      <td>2491</td>\n",
       "      <td>2619</td>\n",
       "      <td>10105</td>\n",
       "      <td>4516</td>\n",
       "      <td>5589</td>\n",
       "      <td>4478</td>\n",
       "      <td>1875</td>\n",
       "      <td>2603</td>\n",
       "      <td>1135</td>\n",
       "      <td>422</td>\n",
       "      <td>713</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        地区       合计       男       女    健康小计   男（健康）   女（健康）  基本健康小计  男（基本健康）  \\\n",
       "0   四    川  1412294  704476  707818  551709  303402  248307  592005   282438   \n",
       "1   山    东  1400109  661388  738721  729311  378178  351133  462980   198008   \n",
       "2   江    苏  1247962  598544  649418  626603  330740  295863  464007   202380   \n",
       "3   河    南  1196924  569894  627030  567448  295386  272062  419979   187347   \n",
       "4   广    东   957360  461728  495632  492653  255966  236687  366579   164524   \n",
       "5   湖    南   939818  469609  470209  330267  185827  144440  413669   197294   \n",
       "6   河    北   928642  450063  478579  419065  223831  195234  341585   153799   \n",
       "7   安    徽   853195  421912  431283  321509  181502  140007  354089   164907   \n",
       "8   湖    北   779566  382160  397406  277089  153831  123258  347418   163091   \n",
       "9   浙    江   759091  377570  381521  400645  215946  184699  266096   119703   \n",
       "10  辽    宁   672227  326082  346145  290920  156959  133961  270482   121123   \n",
       "11  广    西   616828  296065  320763  277551  145405  132146  243746   111190   \n",
       "12  云    南   514563  247803  266760  219938  116480  103458  204988    93409   \n",
       "13  江    西   504043  245931  258112  224487  122278  102209  206832    92353   \n",
       "14  重    庆   488115  245856  242259  195759  107015   88744  201675    97514   \n",
       "15  陕    西   487378  239095  248283  193803  104722   89081  202206    94348   \n",
       "16   黑 龙 江   468616  229664  238952  199247  106452   92795  186754    85349   \n",
       "17  贵    州   446686  217427  229259  189851   99935   89916  170481    79296   \n",
       "18  福    建   420377  206976  213401  209198  111845   97353  163901    74194   \n",
       "19  山    西   414649  205903  208746  166386   92647   73739  165709    77211   \n",
       "20  吉    林   349177  170725  178452  138085   75118   62967  144781    66330   \n",
       "21  上    海   345592  165345  180247  150971   80339   70632  150631    67199   \n",
       "22  甘    肃   338325  168184  170141  118592   66042   52550  137527    65796   \n",
       "23   内 蒙 古   275828  137565  138263  115534   63545   51989  105312    49682   \n",
       "24  北    京   250084  118583  131501   99865   51709   48156  107068    48549   \n",
       "25  新    疆   201515  101793   99722   72501   40531   31970   92420    44866   \n",
       "26  天    津   162233   78029   84204   71973   37875   34098   67182    30285   \n",
       "27  海    南    93525   44616   48909   37806   20174   17632   37809    17311   \n",
       "28  宁    夏    61207   30331   30876   24491   13529   10962   25235    11892   \n",
       "29  青    海    51945   25059   26886   19806   10513    9293   21790    10238   \n",
       "30  西    藏    20828    9304   11524    5110    2491    2619   10105     4516   \n",
       "\n",
       "    女（基本健康）   不健康小计  男（不健康）  女（不健康）  不能自理小计  男（不能自理）  女（不能自理）  \n",
       "0    309567  221883   99155  122728   46697    19481    27216  \n",
       "1    264972  170304   70278  100026   37514    14924    22590  \n",
       "2    261627  127580   53329   74251   29772    12095    17677  \n",
       "3    232632  171312   72514   98798   38185    14647    23538  \n",
       "4    202055   80918   34418   46500   17210     6820    10390  \n",
       "5    216375  167987   74863   93124   27895    11625    16270  \n",
       "6    187786  135863   58852   77011   32129    13581    18548  \n",
       "7    189182  148715   64084   84631   28882    11419    17463  \n",
       "8    184327  131477   55664   75813   23582     9574    14008  \n",
       "9    146393   74373   34152   40221   17977     7769    10208  \n",
       "10   149359   92374   39662   52712   18451     8338    10113  \n",
       "11   132556   81266   33659   47607   14265     5811     8454  \n",
       "12   111579   69556   29771   39785   20081     8143    11938  \n",
       "13   114479   61859   26779   35080   10865     4521     6344  \n",
       "14   104161   75456   34797   40659   15225     6530     8695  \n",
       "15   107858   75574   33210   42364   15795     6815     8980  \n",
       "16   101405   70846   32242   38604   11769     5621     6148  \n",
       "17    91185   71169   31448   39721   15185     6748     8437  \n",
       "18    89707   38889   17525   21364    8389     3412     4977  \n",
       "19    88498   67164   29482   37682   15390     6563     8827  \n",
       "20    78451   57155   24949   32206    9156     4328     4828  \n",
       "21    83432   31175   12607   18568   12815     5200     7615  \n",
       "22    71731   70267   31297   38970   11939     5049     6890  \n",
       "23    55630   45236   19999   25237    9746     4339     5407  \n",
       "24    58519   32082   13652   18430   11069     4673     6396  \n",
       "25    47554   30186   13575   16611    6408     2821     3587  \n",
       "26    36897   17195    7267    9928    5883     2602     3281  \n",
       "27    20498   15030    6041    8989    2880     1090     1790  \n",
       "28    13343    9462    4031    5431    2019      879     1140  \n",
       "29    11552    8436    3552    4884    1913      756     1157  \n",
       "30     5589    4478    1875    2603    1135      422      713  "
      ]
     },
     "execution_count": 208,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "renkou = pd.read_csv(r'C:\\Users\\16019\\Desktop\\决战期末\\各地区分性别健康状况老年人口.csv',encoding=\"gbk\")\n",
    "renkou"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 209,
   "id": "677f2744",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'C:/python/pyecharts-assets-master/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"7e2c27da2eef4b069d3f5aa5884d3448\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_7e2c27da2eef4b069d3f5aa5884d3448 = echarts.init(\n",
       "                    document.getElementById('7e2c27da2eef4b069d3f5aa5884d3448'), 'white', {renderer: 'canvas'});\n",
       "                var option_7e2c27da2eef4b069d3f5aa5884d3448 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                20828,\n",
       "                51945,\n",
       "                61207,\n",
       "                93525,\n",
       "                162233,\n",
       "                201515,\n",
       "                250084,\n",
       "                275828,\n",
       "                338325,\n",
       "                345592,\n",
       "                349177,\n",
       "                414649,\n",
       "                420377,\n",
       "                446686,\n",
       "                468616,\n",
       "                487378,\n",
       "                488115,\n",
       "                504043,\n",
       "                514563,\n",
       "                616828,\n",
       "                672227,\n",
       "                759091,\n",
       "                779566,\n",
       "                853195,\n",
       "                928642,\n",
       "                939818,\n",
       "                957360,\n",
       "                1196924,\n",
       "                1247962,\n",
       "                1400109,\n",
       "                1412294\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"symbolSize\": 80,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u897f    \\u85cf\",\n",
       "                \"\\u9752    \\u6d77\",\n",
       "                \"\\u5b81    \\u590f\",\n",
       "                \"\\u6d77    \\u5357\",\n",
       "                \"\\u5929    \\u6d25\",\n",
       "                \"\\u65b0    \\u7586\",\n",
       "                \"\\u5317    \\u4eac\",\n",
       "                \"\\u5185 \\u8499 \\u53e4\",\n",
       "                \"\\u7518    \\u8083\",\n",
       "                \"\\u4e0a    \\u6d77\",\n",
       "                \"\\u5409    \\u6797\",\n",
       "                \"\\u5c71    \\u897f\",\n",
       "                \"\\u798f    \\u5efa\",\n",
       "                \"\\u8d35    \\u5dde\",\n",
       "                \"\\u9ed1 \\u9f99 \\u6c5f\",\n",
       "                \"\\u9655    \\u897f\",\n",
       "                \"\\u91cd    \\u5e86\",\n",
       "                \"\\u6c5f    \\u897f\",\n",
       "                \"\\u4e91    \\u5357\",\n",
       "                \"\\u5e7f    \\u897f\",\n",
       "                \"\\u8fbd    \\u5b81\",\n",
       "                \"\\u6d59    \\u6c5f\",\n",
       "                \"\\u6e56    \\u5317\",\n",
       "                \"\\u5b89    \\u5fbd\",\n",
       "                \"\\u6cb3    \\u5317\",\n",
       "                \"\\u6e56    \\u5357\",\n",
       "                \"\\u5e7f    \\u4e1c\",\n",
       "                \"\\u6cb3    \\u5357\",\n",
       "                \"\\u6c5f    \\u82cf\",\n",
       "                \"\\u5c71    \\u4e1c\",\n",
       "                \"\\u56db    \\u5ddd\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e2d\\u56fd\\u4eba\\u53e3\\u8001\\u9f84\\u5316\\u5730\\u533a\\u5206\\u5e03\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_7e2c27da2eef4b069d3f5aa5884d3448.setOption(option_7e2c27da2eef4b069d3f5aa5884d3448);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27084c92a90>"
      ]
     },
     "execution_count": 209,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 条形图\n",
    "import random\n",
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Bar\n",
    "\n",
    "x=renkou['地区']\n",
    "x1=list(x)\n",
    "x1.reverse()\n",
    "x1\n",
    "\n",
    "y=renkou['合计']\n",
    "y1=list(y)\n",
    "y1.reverse()\n",
    "y1\n",
    "\n",
    "x_vals1 = x1\n",
    "y_vals = y1\n",
    "bar = Bar().add_xaxis(x_vals1)      \n",
    "bar.add_yaxis('不同省份的老年人口', y_vals, \n",
    "               markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_='average'),\n",
    "                                                 opts.MarkPointItem(type_='max'),\n",
    "                                                 opts.MarkPointItem(type_='min')], \n",
    "                                                symbol_size=80)\n",
    "              ) \n",
    "bar.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='right'))\n",
    "bar.set_global_opts(title_opts=opts.TitleOpts(title='中国人口老龄化地区分布'))\n",
    "bar.reversal_axis() #翻转XY轴，将柱状图转换为条形图\n",
    "bar.render_notebook()\n",
    "# bar.render('条形图.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 210,
   "id": "5e021466",
   "metadata": {},
   "outputs": [],
   "source": [
    "bar = (\n",
    "    Bar(\n",
    "#         init_opts=opts.InitOpts(           # 初始配置项\n",
    "#             theme=ThemeType.MACARONS,\n",
    "#             animation_opts=opts.AnimationOpts(\n",
    "#                 animation_delay=1000, animation_easing=\"cubicOut\"   # 初始动画延迟和缓动效果\n",
    "#             ))\n",
    "        )\n",
    "    # 选取表格中前五个数据\n",
    "    .add_xaxis(xaxis_data=renkou['合计'].tolist())      # x轴\n",
    "    .add_yaxis(series_name=\"中度失能老人\", y_axis=renkou['不健康小计'].tolist(),color=[\"#336699\"])       # y轴\n",
    "    .add_yaxis(series_name=\"重度失能老人\", y_axis=renkou['不能自理小计'].tolist(),color=[\"#99CC33\"])       # y轴\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title='失能老人服务提供者分布',\n",
    "                                  subtitle='', \n",
    "                                  title_textstyle_opts=opts.TextStyleOpts(), pos_left=\"center\", pos_top=\"0\",\n",
    "                                  ),\n",
    "        legend_opts=opts.LegendOpts(orient=\"vertical\", pos_top=\"35%\", pos_right=\"0%\"),\n",
    "        xaxis_opts=opts.AxisOpts(name='服务者', axislabel_opts=opts.LabelOpts(rotate=0)),  # 设置x名称和Label rotate解决标签名字过长使用\n",
    "        yaxis_opts=opts.AxisOpts(name='')\n",
    "          )\n",
    "    .render_notebook()\n",
    "  \n",
    ")\n",
    "        \n",
    "#  bar.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7549bb00",
   "metadata": {},
   "source": [
    "### 地图（√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "a3273b64",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'C:/python/pyecharts-assets-master/assets/echarts.min', 'china':'C:/python/pyecharts-assets-master/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"a2ab2268a7504b5a8612e1fa183e582b\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_a2ab2268a7504b5a8612e1fa183e582b = echarts.init(\n",
       "                    document.getElementById('a2ab2268a7504b5a8612e1fa183e582b'), 'white', {renderer: 'canvas'});\n",
       "                var option_a2ab2268a7504b5a8612e1fa183e582b = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"china\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u56db    \\u5ddd\",\n",
       "                    \"value\": 1412294\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71    \\u4e1c\",\n",
       "                    \"value\": 1400109\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f    \\u82cf\",\n",
       "                    \"value\": 1247962\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3    \\u5357\",\n",
       "                    \"value\": 1196924\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f    \\u4e1c\",\n",
       "                    \"value\": 957360\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56    \\u5357\",\n",
       "                    \"value\": 939818\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3    \\u5317\",\n",
       "                    \"value\": 928642\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89    \\u5fbd\",\n",
       "                    \"value\": 853195\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56    \\u5317\",\n",
       "                    \"value\": 779566\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59    \\u6c5f\",\n",
       "                    \"value\": 759091\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd    \\u5b81\",\n",
       "                    \"value\": 672227\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f    \\u897f\",\n",
       "                    \"value\": 616828\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e91    \\u5357\",\n",
       "                    \"value\": 514563\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f    \\u897f\",\n",
       "                    \"value\": 504043\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd    \\u5e86\",\n",
       "                    \"value\": 488115\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9655    \\u897f\",\n",
       "                    \"value\": 487378\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1 \\u9f99 \\u6c5f\",\n",
       "                    \"value\": 468616\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d35    \\u5dde\",\n",
       "                    \"value\": 446686\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u798f    \\u5efa\",\n",
       "                    \"value\": 420377\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71    \\u897f\",\n",
       "                    \"value\": 414649\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5409    \\u6797\",\n",
       "                    \"value\": 349177\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e0a    \\u6d77\",\n",
       "                    \"value\": 345592\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7518    \\u8083\",\n",
       "                    \"value\": 338325\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5185 \\u8499 \\u53e4\",\n",
       "                    \"value\": 275828\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5317    \\u4eac\",\n",
       "                    \"value\": 250084\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0    \\u7586\",\n",
       "                    \"value\": 201515\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5929    \\u6d25\",\n",
       "                    \"value\": 162233\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77    \\u5357\",\n",
       "                    \"value\": 93525\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b81    \\u590f\",\n",
       "                    \"value\": 61207\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9752    \\u6d77\",\n",
       "                    \"value\": 51945\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f    \\u85cf\",\n",
       "                    \"value\": 20828\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": false,\n",
       "            \"emphasis\": {},\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5168\\u56fd\\u8001\\u5e74\\u4eba\\u53e3\\u5206\\u5e03\\u5730\\u56fe\",\n",
       "            \"subtext\": \"\\u8fd9\\u662f\\u6211\\u56fd\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\\u7684\\u5206\\u5e03\\u5730\\u56fe \\n\\n\\u4ece\\u4e2d\\u6211\\u4eec\\u53ef\\u4ee5\\u770b\\u5230\\u5c71\\u4e1c\\u7701\\u5730\\u533a\\u7684\\u989c\\u8272\\u6700\\u6df1\\uff0c\\u4e5f\\u5c31\\u662f\\u5c71\\u4e1c\\u7701\\u7684\\u8001\\u5e74\\u4eba\\u53e3\\u6570\\u91cf\\u6700\\u591a\\n\\n\\u897f\\u85cf\\u7701\\u5730\\u533a\\u7684\\u989c\\u8272\\u6700\\u6d45\\uff0c\\u4e5f\\u5c31\\u662f\\u897f\\u85cf\\u7684\\u8001\\u5e74\\u4eba\\u53e3\\u6570\\u91cf\\u6700\\u5c11\\uff0c\\u53ef\\u80fd\\u8ddf\\u5f53\\u5730\\u7684\\u5730\\u7406\\u73af\\u5883\\u76f8\\u5173\",\n",
       "            \"top\": \"0\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 20828,\n",
       "        \"max\": 1412294,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#C2E7C0\",\n",
       "                \"#61BDCD\",\n",
       "                \"#0D6DAE\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_a2ab2268a7504b5a8612e1fa183e582b.setOption(option_a2ab2268a7504b5a8612e1fa183e582b);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27085faa310>"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_data = renkou['地区'].tolist()\n",
    "y_data =renkou['合计'].tolist()\n",
    "\n",
    "m = Map()\n",
    "m.add('',[list(z) for z in zip(x_data,y_data)],maptype = 'china',is_map_symbol_show=False)\n",
    "m.set_series_opts(label_opts = opts.LabelOpts(is_show=True))\n",
    "m.set_global_opts(title_opts = opts.TitleOpts(title = '全国老年人口分布地图',\n",
    "                                              subtitle=\"这是我国不同省份的老年人口的分布地图 \\n\\n从中我们可以看到山东省地区的颜色最深，也就是山东省的老年人口数量最多\\n\\n西藏省地区的颜色最浅，也就是西藏的老年人口数量最少，可能跟当地的地理环境相关\",\n",
    "                                                pos_top=\"0\", ),\n",
    "visualmap_opts = opts.VisualMapOpts(min_=renkou['合计'].min(),max_=renkou['合计'].max(),\n",
    "range_color=['#C2E7C0','#61BDCD','#0D6DAE']))\n",
    "m.render_notebook()\n",
    "# m.render('html/全国老年人口分布地图.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b36d1ba",
   "metadata": {},
   "source": [
    "### 柱状图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "224e22ca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"2265e837aa874f99a439cffa109852fc\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_2265e837aa874f99a439cffa109852fc = echarts.init(\n",
       "                    document.getElementById('2265e837aa874f99a439cffa109852fc'), 'white', {renderer: 'canvas'});\n",
       "                var option_2265e837aa874f99a439cffa109852fc = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8001\\u5e74\\u4eba\\u53e3\\u5730\\u533a\\u5206\\u5e03\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                1412294,\n",
       "                1400109,\n",
       "                1247962,\n",
       "                1196924,\n",
       "                957360,\n",
       "                939818,\n",
       "                928642,\n",
       "                853195,\n",
       "                779566,\n",
       "                759091,\n",
       "                672227,\n",
       "                616828,\n",
       "                514563,\n",
       "                504043,\n",
       "                488115,\n",
       "                487378,\n",
       "                468616,\n",
       "                446686,\n",
       "                420377,\n",
       "                414649,\n",
       "                349177,\n",
       "                345592,\n",
       "                338325,\n",
       "                275828,\n",
       "                250084,\n",
       "                201515,\n",
       "                162233,\n",
       "                93525,\n",
       "                61207,\n",
       "                51945,\n",
       "                20828\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8001\\u5e74\\u4eba\\u53e3\\u5730\\u533a\\u5206\\u5e03\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8001\\u5e74\\u4eba\\u53e3\\u5730\\u533a\\u5206\\u5e03\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u56db    \\u5ddd\",\n",
       "                \"\\u5c71    \\u4e1c\",\n",
       "                \"\\u6c5f    \\u82cf\",\n",
       "                \"\\u6cb3    \\u5357\",\n",
       "                \"\\u5e7f    \\u4e1c\",\n",
       "                \"\\u6e56    \\u5357\",\n",
       "                \"\\u6cb3    \\u5317\",\n",
       "                \"\\u5b89    \\u5fbd\",\n",
       "                \"\\u6e56    \\u5317\",\n",
       "                \"\\u6d59    \\u6c5f\",\n",
       "                \"\\u8fbd    \\u5b81\",\n",
       "                \"\\u5e7f    \\u897f\",\n",
       "                \"\\u4e91    \\u5357\",\n",
       "                \"\\u6c5f    \\u897f\",\n",
       "                \"\\u91cd    \\u5e86\",\n",
       "                \"\\u9655    \\u897f\",\n",
       "                \"\\u9ed1 \\u9f99 \\u6c5f\",\n",
       "                \"\\u8d35    \\u5dde\",\n",
       "                \"\\u798f    \\u5efa\",\n",
       "                \"\\u5c71    \\u897f\",\n",
       "                \"\\u5409    \\u6797\",\n",
       "                \"\\u4e0a    \\u6d77\",\n",
       "                \"\\u7518    \\u8083\",\n",
       "                \"\\u5185 \\u8499 \\u53e4\",\n",
       "                \"\\u5317    \\u4eac\",\n",
       "                \"\\u65b0    \\u7586\",\n",
       "                \"\\u5929    \\u6d25\",\n",
       "                \"\\u6d77    \\u5357\",\n",
       "                \"\\u5b81    \\u590f\",\n",
       "                \"\\u9752    \\u6d77\",\n",
       "                \"\\u897f    \\u85cf\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8001\\u5e74\\u4eba\\u53e3\\u5730\\u533a\\u5206\\u5e03\",\n",
       "            \"subtext\": \"\\u8fd9\\u662f\\u6211\\u56fd\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\\u7684\\u5206\\u5e03\\u5730\\u56fe\\uff0c\\u4ece\\u4e2d\\u6211\\u4eec\\u53ef\\u4ee5\\u770b\\u5230\\u5c71\\u4e1c\\u7701\\u5730\\u533a\\u7684\\u989c\\u8272\\u6700\\u6df1\\uff0c\\u4e5f\\u5c31\\u662f\\u5c71\\u4e1c\\u7701\\u7684\\u8001\\u5e74\\u4eba\\u53e3\\u6570\\u91cf\\u6700\\u591a\",\n",
       "            \"top\": \"0\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_2265e837aa874f99a439cffa109852fc.setOption(option_2265e837aa874f99a439cffa109852fc);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27083e720a0>"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Bar\n",
    "#xy轴数据\n",
    "x= renkou['地区']\n",
    "x1=list(x)\n",
    "\n",
    "y=renkou['合计']\n",
    "y1=list(y)\n",
    "\n",
    "#柱形图\n",
    "l1=x1\n",
    "l2=y1\n",
    "bar = (\n",
    "    Bar()\n",
    "    .add_xaxis(l1)\n",
    "    .add_yaxis(\"老年人口地区分布\", l2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"老年人口地区分布\",\n",
    "                                                subtitle=\"这是我国不同省份的老年人口的分布地图，从中我们可以看到山东省地区的颜色最深，也就是山东省的老年人口数量最多\",\n",
    "                                                pos_top=\"0\", ),\n",
    "                     datazoom_opts=opts.DataZoomOpts(type_=\"slider\"))\n",
    ")\n",
    "bar.render_notebook()\n",
    "# bar.render('不同行业公司数量图.html')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2182d27e",
   "metadata": {},
   "source": [
    "### 条形图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "58714eb9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"626ccb67bbf845fba8da7971068132f2\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_626ccb67bbf845fba8da7971068132f2 = echarts.init(\n",
       "                    document.getElementById('626ccb67bbf845fba8da7971068132f2'), 'white', {renderer: 'canvas'});\n",
       "                var option_626ccb67bbf845fba8da7971068132f2 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                20828,\n",
       "                51945,\n",
       "                61207,\n",
       "                93525,\n",
       "                162233,\n",
       "                201515,\n",
       "                250084,\n",
       "                275828,\n",
       "                338325,\n",
       "                345592,\n",
       "                349177,\n",
       "                414649,\n",
       "                420377,\n",
       "                446686,\n",
       "                468616,\n",
       "                487378,\n",
       "                488115,\n",
       "                504043,\n",
       "                514563,\n",
       "                616828,\n",
       "                672227,\n",
       "                759091,\n",
       "                779566,\n",
       "                853195,\n",
       "                928642,\n",
       "                939818,\n",
       "                957360,\n",
       "                1196924,\n",
       "                1247962,\n",
       "                1400109,\n",
       "                1412294\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"symbolSize\": 80,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u897f    \\u85cf\",\n",
       "                \"\\u9752    \\u6d77\",\n",
       "                \"\\u5b81    \\u590f\",\n",
       "                \"\\u6d77    \\u5357\",\n",
       "                \"\\u5929    \\u6d25\",\n",
       "                \"\\u65b0    \\u7586\",\n",
       "                \"\\u5317    \\u4eac\",\n",
       "                \"\\u5185 \\u8499 \\u53e4\",\n",
       "                \"\\u7518    \\u8083\",\n",
       "                \"\\u4e0a    \\u6d77\",\n",
       "                \"\\u5409    \\u6797\",\n",
       "                \"\\u5c71    \\u897f\",\n",
       "                \"\\u798f    \\u5efa\",\n",
       "                \"\\u8d35    \\u5dde\",\n",
       "                \"\\u9ed1 \\u9f99 \\u6c5f\",\n",
       "                \"\\u9655    \\u897f\",\n",
       "                \"\\u91cd    \\u5e86\",\n",
       "                \"\\u6c5f    \\u897f\",\n",
       "                \"\\u4e91    \\u5357\",\n",
       "                \"\\u5e7f    \\u897f\",\n",
       "                \"\\u8fbd    \\u5b81\",\n",
       "                \"\\u6d59    \\u6c5f\",\n",
       "                \"\\u6e56    \\u5317\",\n",
       "                \"\\u5b89    \\u5fbd\",\n",
       "                \"\\u6cb3    \\u5317\",\n",
       "                \"\\u6e56    \\u5357\",\n",
       "                \"\\u5e7f    \\u4e1c\",\n",
       "                \"\\u6cb3    \\u5357\",\n",
       "                \"\\u6c5f    \\u82cf\",\n",
       "                \"\\u5c71    \\u4e1c\",\n",
       "                \"\\u56db    \\u5ddd\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e2d\\u56fd\\u4eba\\u53e3\\u8001\\u9f84\\u5316\\u5730\\u533a\\u5206\\u5e03\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_626ccb67bbf845fba8da7971068132f2.setOption(option_626ccb67bbf845fba8da7971068132f2);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x270835334c0>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 条形图\n",
    "import random\n",
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Bar\n",
    "\n",
    "x=renkou['地区']\n",
    "x1=list(x)\n",
    "x1.reverse()\n",
    "x1\n",
    "\n",
    "y=renkou['合计']\n",
    "y1=list(y)\n",
    "y1.reverse()\n",
    "y1\n",
    "\n",
    "x_vals1 = x1\n",
    "y_vals = y1\n",
    "bar = Bar().add_xaxis(x_vals1)      \n",
    "bar.add_yaxis('不同省份的老年人口', y_vals, \n",
    "               markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_='average'),\n",
    "                                                 opts.MarkPointItem(type_='max'),\n",
    "                                                 opts.MarkPointItem(type_='min')], \n",
    "                                                symbol_size=80)\n",
    "              ) \n",
    "bar.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='right'))\n",
    "bar.set_global_opts(title_opts=opts.TitleOpts(title='中国人口老龄化地区分布'))\n",
    "bar.reversal_axis() #翻转XY轴，将柱状图转换为条形图\n",
    "bar.render_notebook()\n",
    "# bar.render('条形图.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a7dbb7c0",
   "metadata": {},
   "source": [
    "## 老年人口不同类型分布"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "9e4b65e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>老龄人口</th>\n",
       "      <th>占比(%)</th>\n",
       "      <th>Unnamed: 2</th>\n",
       "      <th>Unnamed: 3</th>\n",
       "      <th>Unnamed: 4</th>\n",
       "      <th>Unnamed: 5</th>\n",
       "      <th>Unnamed: 6</th>\n",
       "      <th>Unnamed: 7</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>空巢老人</td>\n",
       "      <td>49</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>失能老人</td>\n",
       "      <td>17</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>高龄老人</td>\n",
       "      <td>12</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>其他</td>\n",
       "      <td>22</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   老龄人口  占比(%)  Unnamed: 2  Unnamed: 3  Unnamed: 4  Unnamed: 5  Unnamed: 6  \\\n",
       "0  空巢老人     49         NaN         NaN         NaN         NaN         NaN   \n",
       "1  失能老人     17         NaN         NaN         NaN         NaN         NaN   \n",
       "2  高龄老人     12         NaN         NaN         NaN         NaN         NaN   \n",
       "3    其他     22         NaN         NaN         NaN         NaN         NaN   \n",
       "\n",
       "   Unnamed: 7  \n",
       "0         NaN  \n",
       "1         NaN  \n",
       "2         NaN  \n",
       "3         NaN  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bizhong = pd.read_csv('data/中国老龄人口比重分布.csv',encoding=\"gbk\")\n",
    "bizhong "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "76d7b7e9",
   "metadata": {},
   "source": [
    "### 饼图(√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "42a77be3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"6bc23bce3a384f6b8f7d652367149113\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_6bc23bce3a384f6b8f7d652367149113 = echarts.init(\n",
       "                    document.getElementById('6bc23bce3a384f6b8f7d652367149113'), 'white', {renderer: 'canvas'});\n",
       "                var option_6bc23bce3a384f6b8f7d652367149113 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u7a7a\\u5de2\\u8001\\u4eba\",\n",
       "                    \"value\": 49\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5931\\u80fd\\u8001\\u4eba\",\n",
       "                    \"value\": 17\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ad8\\u9f84\\u8001\\u4eba\",\n",
       "                    \"value\": 12\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5176\\u4ed6\",\n",
       "                    \"value\": 22\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c}\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u7a7a\\u5de2\\u8001\\u4eba\",\n",
       "                \"\\u5931\\u80fd\\u8001\\u4eba\",\n",
       "                \"\\u9ad8\\u9f84\\u8001\\u4eba\",\n",
       "                \"\\u5176\\u4ed6\"\n",
       "            ],\n",
       "            \"selected\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    }\n",
       "};\n",
       "                chart_6bc23bce3a384f6b8f7d652367149113.setOption(option_6bc23bce3a384f6b8f7d652367149113);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27082627100>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x=bizhong[\"老龄人口\"]\n",
    "x_data=list(x)\n",
    "y=bizhong[\"占比(%)\"]\n",
    "y_data=list(y)\n",
    "c = (\n",
    "    Pie()\n",
    "    .add(\"\", [list(z) for z in zip(x_data, y_data)])   # zip函数两个部分组合在一起list(zip(x,y))-----> [(x,y)]\n",
    "#     .set_global_opts(title_opts=opts.TitleOpts(title=\"三大湾区总估值\"))  # 标题\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c}\"))  # 数据标签设置\n",
    ")\n",
    "\n",
    "c.render_notebook()\n",
    "# c.render('html/老龄人口比重.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1507470b",
   "metadata": {},
   "source": [
    "## 老年人口最担忧的养老问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "id": "8d2b2254",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>担忧的问题</th>\n",
       "      <th>占比（%）</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>医疗费</td>\n",
       "      <td>59.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>大病未及时发现治疗</td>\n",
       "      <td>48.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>缺乏护理、治疗</td>\n",
       "      <td>29.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日常生活困难</td>\n",
       "      <td>20.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>亲人团聚少</td>\n",
       "      <td>19.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>社交人情冷落</td>\n",
       "      <td>14.3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       担忧的问题  占比（%）\n",
       "0        医疗费   59.5\n",
       "1  大病未及时发现治疗   48.7\n",
       "2    缺乏护理、治疗   29.3\n",
       "3     日常生活困难   20.9\n",
       "4      亲人团聚少   19.6\n",
       "5     社交人情冷落   14.3"
      ]
     },
     "execution_count": 196,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wenti=pd.read_excel('data/最担忧的养老问题占比.xlsx',\n",
    "                        sheet_name='数据'\n",
    "                     )\n",
    "wenti"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "03486c68",
   "metadata": {},
   "source": [
    "### 柱形图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "85e0447d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"ccd5e44c78074e559cc42ba94eff00a3\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_ccd5e44c78074e559cc42ba94eff00a3 = echarts.init(\n",
       "                    document.getElementById('ccd5e44c78074e559cc42ba94eff00a3'), 'white', {renderer: 'canvas'});\n",
       "                var option_ccd5e44c78074e559cc42ba94eff00a3 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                3340,\n",
       "                2596,\n",
       "                2504,\n",
       "                2494,\n",
       "                2417,\n",
       "                2271,\n",
       "                2171,\n",
       "                2055,\n",
       "                1968,\n",
       "                1958,\n",
       "                1854,\n",
       "                1782,\n",
       "                1678,\n",
       "                1520,\n",
       "                1146,\n",
       "                968,\n",
       "                903,\n",
       "                774,\n",
       "                763,\n",
       "                762,\n",
       "                681,\n",
       "                665,\n",
       "                588,\n",
       "                571,\n",
       "                407,\n",
       "                396,\n",
       "                278,\n",
       "                131,\n",
       "                64,\n",
       "                59,\n",
       "                53\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u6cb3\\u5357\\u7701\",\n",
       "                \"\\u5b89\\u5fbd\\u7701\",\n",
       "                \"\\u56db\\u5ddd\\u7701\",\n",
       "                \"\\u6c5f\\u82cf\\u7701\",\n",
       "                \"\\u6e56\\u5357\\u7701\",\n",
       "                \"\\u5c71\\u4e1c\\u7701\",\n",
       "                \"\\u8fbd\\u5b81\\u7701\",\n",
       "                \"\\u9ed1\\u9f99\\u6c5f\\u7701\",\n",
       "                \"\\u6e56\\u5317\\u7701\",\n",
       "                \"\\u5e7f\\u4e1c\\u7701\",\n",
       "                \"\\u6c5f\\u897f\\u7701\",\n",
       "                \"\\u6cb3\\u5317\\u7701\",\n",
       "                \"\\u6d59\\u6c5f\\u7701\",\n",
       "                \"\\u5409\\u6797\\u7701\",\n",
       "                \"\\u91cd\\u5e86\\u5e02\",\n",
       "                \"\\u8d35\\u5dde\\u7701\",\n",
       "                \"\\u4e91\\u5357\\u7701\",\n",
       "                \"\\u5c71\\u897f\\u7701\",\n",
       "                \"\\u9655\\u897f\\u7701\",\n",
       "                \"\\u798f\\u5efa\\u7701\",\n",
       "                \"\\u4e0a\\u6d77\\u5e02\",\n",
       "                \"\\u5185\\u8499\\u53e4\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u5e7f\\u897f\\u58ee\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u5317\\u4eac\\u5e02\",\n",
       "                \"\\u5929\\u6d25\\u5e02\",\n",
       "                \"\\u65b0\\u7586\\u7ef4\\u543e\\u5c14\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u7518\\u8083\\u7701\",\n",
       "                \"\\u5b81\\u590f\\u56de\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u9752\\u6d77\\u7701\",\n",
       "                \"\\u6d77\\u5357\\u7701\",\n",
       "                \"\\u897f\\u85cf\\u81ea\\u6cbb\\u533a\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_ccd5e44c78074e559cc42ba94eff00a3.setOption(option_ccd5e44c78074e559cc42ba94eff00a3);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27083533f70>"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Bar\n",
    "#xy轴数据\n",
    "x= jigou['省份']\n",
    "x1=list(x)\n",
    "\n",
    "y=jigou['养老机构(个)']\n",
    "y1=list(y)\n",
    "\n",
    "#柱形图\n",
    "l1=x1\n",
    "l2=y1\n",
    "bar = (\n",
    "    Bar()\n",
    "    .add_xaxis(l1)\n",
    "    .add_yaxis(\"不同养老机构服务价格\", l2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"不同养老机构服务价格\"),\n",
    "                     datazoom_opts=opts.DataZoomOpts(type_=\"slider\"))\n",
    ")\n",
    "bar.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f57a7f44",
   "metadata": {},
   "source": [
    "### 条形图（√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "61ff2482",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"cf80d8877f1440c7bfbe0198093380f1\" style=\"width:1200px; height:800px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_cf80d8877f1440c7bfbe0198093380f1 = echarts.init(\n",
       "                    document.getElementById('cf80d8877f1440c7bfbe0198093380f1'), 'white', {renderer: 'canvas'});\n",
       "                var option_cf80d8877f1440c7bfbe0198093380f1 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                53,\n",
       "                59,\n",
       "                64,\n",
       "                131,\n",
       "                278,\n",
       "                396,\n",
       "                407,\n",
       "                571,\n",
       "                588,\n",
       "                665,\n",
       "                681,\n",
       "                762,\n",
       "                763,\n",
       "                774,\n",
       "                903,\n",
       "                968,\n",
       "                1146,\n",
       "                1520,\n",
       "                1678,\n",
       "                1782,\n",
       "                1854,\n",
       "                1958,\n",
       "                1968,\n",
       "                2055,\n",
       "                2171,\n",
       "                2271,\n",
       "                2417,\n",
       "                2494,\n",
       "                2504,\n",
       "                2596,\n",
       "                3340\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"symbolSize\": 80,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u897f\\u85cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u6d77\\u5357\\u7701\",\n",
       "                \"\\u9752\\u6d77\\u7701\",\n",
       "                \"\\u5b81\\u590f\\u56de\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u7518\\u8083\\u7701\",\n",
       "                \"\\u65b0\\u7586\\u7ef4\\u543e\\u5c14\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u5929\\u6d25\\u5e02\",\n",
       "                \"\\u5317\\u4eac\\u5e02\",\n",
       "                \"\\u5e7f\\u897f\\u58ee\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u5185\\u8499\\u53e4\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u4e0a\\u6d77\\u5e02\",\n",
       "                \"\\u798f\\u5efa\\u7701\",\n",
       "                \"\\u9655\\u897f\\u7701\",\n",
       "                \"\\u5c71\\u897f\\u7701\",\n",
       "                \"\\u4e91\\u5357\\u7701\",\n",
       "                \"\\u8d35\\u5dde\\u7701\",\n",
       "                \"\\u91cd\\u5e86\\u5e02\",\n",
       "                \"\\u5409\\u6797\\u7701\",\n",
       "                \"\\u6d59\\u6c5f\\u7701\",\n",
       "                \"\\u6cb3\\u5317\\u7701\",\n",
       "                \"\\u6c5f\\u897f\\u7701\",\n",
       "                \"\\u5e7f\\u4e1c\\u7701\",\n",
       "                \"\\u6e56\\u5317\\u7701\",\n",
       "                \"\\u9ed1\\u9f99\\u6c5f\\u7701\",\n",
       "                \"\\u8fbd\\u5b81\\u7701\",\n",
       "                \"\\u5c71\\u4e1c\\u7701\",\n",
       "                \"\\u6e56\\u5357\\u7701\",\n",
       "                \"\\u6c5f\\u82cf\\u7701\",\n",
       "                \"\\u56db\\u5ddd\\u7701\",\n",
       "                \"\\u5b89\\u5fbd\\u7701\",\n",
       "                \"\\u6cb3\\u5357\\u7701\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_cf80d8877f1440c7bfbe0198093380f1.setOption(option_cf80d8877f1440c7bfbe0198093380f1);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27083db2910>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 条形图\n",
    "import random\n",
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Bar\n",
    "\n",
    "x=jigou['省份']\n",
    "x1=list(x)\n",
    "x1.reverse()\n",
    "\n",
    "y=jigou['养老机构(个)']\n",
    "y1=list(y)\n",
    "y1.reverse()\n",
    "\n",
    "x_vals1 = x1\n",
    "y_vals = y1\n",
    "bar = Bar(init_opts=opts.InitOpts(width=\"1200px\",height='800px')).add_xaxis(x_vals1)  \n",
    "bar.add_yaxis('不同省份的养老机构数量', y_vals, \n",
    "               markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_='average'),\n",
    "                                                 opts.MarkPointItem(type_='max'),\n",
    "                                                 opts.MarkPointItem(type_='min')], \n",
    "                                                symbol_size=80)\n",
    "              ) \n",
    "bar.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='right'))\n",
    "bar.set_global_opts(title_opts=opts.TitleOpts(title='不同省份的养老机构数量'))\n",
    "bar.reversal_axis() #翻转XY轴，将柱状图转换为条形图\n",
    "bar.render_notebook()\n",
    "# bar.render('html/不同省份老年机构数量.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0d0bfe0c",
   "metadata": {},
   "source": [
    "## 不同年份养老机构数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "75623fcc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>年份</th>\n",
       "      <th>养老服务机构和设施总数(万个)</th>\n",
       "      <th>养老服务机构(万个)</th>\n",
       "      <th>社区养老服务机构和设施(万个)</th>\n",
       "      <th>互助型的养老设施(万个)</th>\n",
       "      <th>养老机构入住率(%)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2010</td>\n",
       "      <td>4.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2011</td>\n",
       "      <td>4.1</td>\n",
       "      <td>4.1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2012</td>\n",
       "      <td>4.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2013</td>\n",
       "      <td>4.3</td>\n",
       "      <td>4.3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2014</td>\n",
       "      <td>9.4</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.9</td>\n",
       "      <td>4.0</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2015</td>\n",
       "      <td>11.6</td>\n",
       "      <td>2.8</td>\n",
       "      <td>2.6</td>\n",
       "      <td>6.2</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2016</td>\n",
       "      <td>14.0</td>\n",
       "      <td>2.9</td>\n",
       "      <td>3.5</td>\n",
       "      <td>7.6</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2017</td>\n",
       "      <td>15.5</td>\n",
       "      <td>2.9</td>\n",
       "      <td>4.3</td>\n",
       "      <td>8.3</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     年份  养老服务机构和设施总数(万个)  养老服务机构(万个)  社区养老服务机构和设施(万个)  互助型的养老设施(万个)  \\\n",
       "0  2010              4.0         4.0              NaN           NaN   \n",
       "1  2011              4.1         4.1              NaN           NaN   \n",
       "2  2012              4.4         4.4              NaN           NaN   \n",
       "3  2013              4.3         4.3              NaN           NaN   \n",
       "4  2014              9.4         3.3              1.9           4.0   \n",
       "5  2015             11.6         2.8              2.6           6.2   \n",
       "6  2016             14.0         2.9              3.5           7.6   \n",
       "7  2017             15.5         2.9              4.3           8.3   \n",
       "\n",
       "   养老机构入住率(%)  \n",
       "0          79  \n",
       "1          77  \n",
       "2          74  \n",
       "3          70  \n",
       "4          62  \n",
       "5          55  \n",
       "6          52  \n",
       "7          48  "
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nianfen=pd.read_excel('data/不同年份养老机构数量.xlsx',\n",
    "                        sheet_name='数据'\n",
    "                     )\n",
    "nianfen"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d7c7a85",
   "metadata": {},
   "source": [
    "### 柱状图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "a1819c9f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"7cc27fc672044fab8ddbad35a3c097ab\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_7cc27fc672044fab8ddbad35a3c097ab = echarts.init(\n",
       "                    document.getElementById('7cc27fc672044fab8ddbad35a3c097ab'), 'white', {renderer: 'canvas'});\n",
       "                var option_7cc27fc672044fab8ddbad35a3c097ab = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                4.0,\n",
       "                4.1,\n",
       "                4.4,\n",
       "                4.3,\n",
       "                9.4,\n",
       "                11.6,\n",
       "                14.0,\n",
       "                15.5\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                2010,\n",
       "                2011,\n",
       "                2012,\n",
       "                2013,\n",
       "                2014,\n",
       "                2015,\n",
       "                2016,\n",
       "                2017\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_7cc27fc672044fab8ddbad35a3c097ab.setOption(option_7cc27fc672044fab8ddbad35a3c097ab);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27083e1bc10>"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Bar\n",
    "#xy轴数据\n",
    "x= nianfen[\"年份\"]\n",
    "x1=list(x)\n",
    "\n",
    "y=nianfen[\"养老服务机构和设施总数(万个)\"]\n",
    "y1=list(y)\n",
    "\n",
    "#柱形图\n",
    "l1=x1\n",
    "l2=y1\n",
    "bar = (\n",
    "    Bar()\n",
    "    .add_xaxis(l1)\n",
    "    .add_yaxis(\"不同年份养老机构数量\", l2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"不同年份养老机构数量\"),\n",
    "                     datazoom_opts=opts.DataZoomOpts(type_=\"slider\"))\n",
    ")\n",
    "bar.render_notebook()\n",
    "# bar.render('html/不同养老机构服务价格.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dda58172",
   "metadata": {},
   "source": [
    "### 折线图（无标签）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "62d92711",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x= nianfen[\"年份\"]\n",
    "x1=list(x)\n",
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "bd3caceb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[4.0, 4.1, 4.4, 4.3, 9.4, 11.6, 14.0, 15.5]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y=nianfen[\"养老服务机构和设施总数(万个)\"]\n",
    "y1=list(y)\n",
    "y1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "ce769509",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"e482093921b6444eb036eaa5041a02ad\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_e482093921b6444eb036eaa5041a02ad = echarts.init(\n",
       "                    document.getElementById('e482093921b6444eb036eaa5041a02ad'), 'white', {renderer: 'canvas'});\n",
       "                var option_e482093921b6444eb036eaa5041a02ad = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u57fa\\u672c\\u6298\\u7ebf\\u56fe\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbol\": \"emptyCircle\",\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    4.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    4.1\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u661f\\u671f\\u4e09\",\n",
       "                    4.4\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u661f\\u671f\\u56db\",\n",
       "                    4.3\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u661f\\u671f\\u4e94\",\n",
       "                    9.4\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u661f\\u671f\\u4e03\",\n",
       "                    11.6\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u661f\\u671f\\u65e5\",\n",
       "                    14.0\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u57fa\\u672c\\u6298\\u7ebf\\u56fe\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u57fa\\u672c\\u6298\\u7ebf\\u56fe\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": false,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"type\": \"category\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2010\",\n",
       "                \"2011\",\n",
       "                \"\\u661f\\u671f\\u4e09\",\n",
       "                \"\\u661f\\u671f\\u56db\",\n",
       "                \"\\u661f\\u671f\\u4e94\",\n",
       "                \"\\u661f\\u671f\\u4e03\",\n",
       "                \"\\u661f\\u671f\\u65e5\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"type\": \"value\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"axisTick\": {\n",
       "                \"show\": true,\n",
       "                \"alignWithLabel\": false,\n",
       "                \"inside\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_e482093921b6444eb036eaa5041a02ad.setOption(option_e482093921b6444eb036eaa5041a02ad);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x270834a5370>"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Line\n",
    "x=['2010','2011','星期三','星期四','星期五','星期七','星期日']\n",
    "y=y1\n",
    "\n",
    "line=(\n",
    "    Line()\n",
    "    .set_global_opts(\n",
    "        tooltip_opts=opts.TooltipOpts(is_show=False),\n",
    "        xaxis_opts=opts.AxisOpts(type_=\"category\"),\n",
    "        yaxis_opts=opts.AxisOpts(\n",
    "            type_=\"value\",\n",
    "            axistick_opts=opts.AxisTickOpts(is_show=True),\n",
    "            splitline_opts=opts.SplitLineOpts(is_show=True),\n",
    "        ),\n",
    "    )\n",
    "    .add_xaxis(xaxis_data=x)\n",
    "    .add_yaxis(\n",
    "        series_name=\"基本折线图\",\n",
    "        y_axis=y,\n",
    "        symbol=\"emptyCircle\",\n",
    "        is_symbol_show=True,\n",
    "        label_opts=opts.LabelOpts(is_show=False),\n",
    "    )\n",
    ")\n",
    "line.render_notebook()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4218dffb",
   "metadata": {},
   "source": [
    "### 折线图（有标签）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "265ffd17",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"51bf38d787b04fed96ba3f4d7a3ee8f5\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_51bf38d787b04fed96ba3f4d7a3ee8f5 = echarts.init(\n",
       "                    document.getElementById('51bf38d787b04fed96ba3f4d7a3ee8f5'), 'white', {renderer: 'canvas'});\n",
       "                var option_51bf38d787b04fed96ba3f4d7a3ee8f5 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\",\n",
       "            \"connectNulls\": true,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    4.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    4.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\",\n",
       "                    4.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\",\n",
       "                    4.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\",\n",
       "                    9.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\",\n",
       "                    11.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\",\n",
       "                    14.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2017\",\n",
       "                    15.5\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2010\",\n",
       "                \"2011\",\n",
       "                \"2012\",\n",
       "                \"2013\",\n",
       "                \"2014\",\n",
       "                \"2015\",\n",
       "                \"2016\",\n",
       "                \"2017\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Line-\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_51bf38d787b04fed96ba3f4d7a3ee8f5.setOption(option_51bf38d787b04fed96ba3f4d7a3ee8f5);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27083e1b640>"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Line\n",
    "\n",
    "\n",
    "x=['2010','2011','2012','2013','2014','2015','2016','2017']\n",
    "y=y1\n",
    "\n",
    "line=(\n",
    "    Line()\n",
    "    .add_xaxis(xaxis_data=x)\n",
    "    .add_yaxis(\n",
    "        series_name=\"连接空数据（折线图）\",\n",
    "        y_axis=y,\n",
    "        is_connect_nones=True\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"Line-连接空数据\"))\n",
    ")\n",
    "line.render_notebook()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e147fb44",
   "metadata": {},
   "source": [
    "### 折线图与柱状图合体"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "8fcc3db4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pyecharts.charts.basic_charts.bar.Bar at 0x27083d9fa30>"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all=bar.overlap(line)\n",
    "all"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "18d8ab41",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "from  pyecharts import options as  opts\n",
    "\n",
    "\n",
    "from pyecharts.charts import Pie\n",
    "\n",
    "\n",
    "from pyecharts.globals import ThemeType\n",
    "\n",
    "\n",
    "from  pyecharts.charts import Bar\n",
    "\n",
    "from  pyecharts.charts import  Line\n",
    "\n",
    "from  pyecharts.charts import  *\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "c32c95e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pyecharts.charts.composite_charts.grid.Grid at 0x27083dbcc10>"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aa=Grid(\n",
    "    #画布配置\n",
    "    init_opts=opts.InitOpts(\n",
    "        width=\"1500px\",  #图的大小\n",
    "        height='650px',\n",
    "\n",
    "))\n",
    "aa.add(all,\n",
    "       #网格配置\n",
    "       grid_opts=opts.GridOpts(\n",
    "           pos_top=\"20%\",\n",
    "           pos_left=\"5%\",\n",
    "           pos_right=\"40%\",\n",
    "       ),\n",
    "       # 索引\n",
    "       is_control_axis_index=True #控制索引\n",
    "       )\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "eb1ec3a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"42dcb9e5eed34ba3845db3d4bbe39e06\" style=\"width:1500px; height:650px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_42dcb9e5eed34ba3845db3d4bbe39e06 = echarts.init(\n",
       "                    document.getElementById('42dcb9e5eed34ba3845db3d4bbe39e06'), 'white', {renderer: 'canvas'});\n",
       "                var option_42dcb9e5eed34ba3845db3d4bbe39e06 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                4.0,\n",
       "                4.1,\n",
       "                4.4,\n",
       "                4.3,\n",
       "                9.4,\n",
       "                11.6,\n",
       "                14.0,\n",
       "                15.5\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\",\n",
       "            \"connectNulls\": true,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    4.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    4.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\",\n",
       "                    4.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\",\n",
       "                    4.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\",\n",
       "                    9.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\",\n",
       "                    11.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\",\n",
       "                    14.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2017\",\n",
       "                    15.5\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "                \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\": true,\n",
       "                \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                2010,\n",
       "                2011,\n",
       "                2012,\n",
       "                2013,\n",
       "                2014,\n",
       "                2015,\n",
       "                2016,\n",
       "                2017\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    },\n",
       "    \"grid\": [\n",
       "        {\n",
       "            \"show\": false,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"left\": \"5%\",\n",
       "            \"top\": \"20%\",\n",
       "            \"right\": \"40%\",\n",
       "            \"containLabel\": false,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_42dcb9e5eed34ba3845db3d4bbe39e06.setOption(option_42dcb9e5eed34ba3845db3d4bbe39e06);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27083e006a0>"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aa.render('./疫情数据.html')\n",
    "aa.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fef561b4",
   "metadata": {},
   "source": [
    "## 养老机构数量与入住率"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "3be4e99f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>年份</th>\n",
       "      <th>养老服务机构和设施总数(万个)</th>\n",
       "      <th>养老服务机构(万个)</th>\n",
       "      <th>社区养老服务机构和设施(万个)</th>\n",
       "      <th>互助型的养老设施(万个)</th>\n",
       "      <th>养老机构入住率(%)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2010</td>\n",
       "      <td>4.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2011</td>\n",
       "      <td>4.1</td>\n",
       "      <td>4.1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2012</td>\n",
       "      <td>4.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2013</td>\n",
       "      <td>4.3</td>\n",
       "      <td>4.3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2014</td>\n",
       "      <td>9.4</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.9</td>\n",
       "      <td>4.0</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2015</td>\n",
       "      <td>11.6</td>\n",
       "      <td>2.8</td>\n",
       "      <td>2.6</td>\n",
       "      <td>6.2</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2016</td>\n",
       "      <td>14.0</td>\n",
       "      <td>2.9</td>\n",
       "      <td>3.5</td>\n",
       "      <td>7.6</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2017</td>\n",
       "      <td>15.5</td>\n",
       "      <td>2.9</td>\n",
       "      <td>4.3</td>\n",
       "      <td>8.3</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     年份  养老服务机构和设施总数(万个)  养老服务机构(万个)  社区养老服务机构和设施(万个)  互助型的养老设施(万个)  \\\n",
       "0  2010              4.0         4.0              NaN           NaN   \n",
       "1  2011              4.1         4.1              NaN           NaN   \n",
       "2  2012              4.4         4.4              NaN           NaN   \n",
       "3  2013              4.3         4.3              NaN           NaN   \n",
       "4  2014              9.4         3.3              1.9           4.0   \n",
       "5  2015             11.6         2.8              2.6           6.2   \n",
       "6  2016             14.0         2.9              3.5           7.6   \n",
       "7  2017             15.5         2.9              4.3           8.3   \n",
       "\n",
       "   养老机构入住率(%)  \n",
       "0          79  \n",
       "1          77  \n",
       "2          74  \n",
       "3          70  \n",
       "4          62  \n",
       "5          55  \n",
       "6          52  \n",
       "7          48  "
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nianfen=pd.read_excel('data/不同年份养老机构数量.xlsx', sheet_name='数据')\n",
    "nianfen"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8f04e80e",
   "metadata": {},
   "source": [
    "### 折线图(√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "2844da89",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"7cb9c8ae541a47a0ac32a6c1bcdcd3cc\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_7cb9c8ae541a47a0ac32a6c1bcdcd3cc = echarts.init(\n",
       "                    document.getElementById('7cb9c8ae541a47a0ac32a6c1bcdcd3cc'), 'white', {renderer: 'canvas'});\n",
       "                var option_7cb9c8ae541a47a0ac32a6c1bcdcd3cc = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\\uff08\\u4e07\\u4e2a\\uff09\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbol\": \"arrow\",\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    4.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    4.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\",\n",
       "                    4.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\",\n",
       "                    4.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\",\n",
       "                    9.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\",\n",
       "                    11.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\",\n",
       "                    14.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2017\",\n",
       "                    15.5\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u517b\\u8001\\u673a\\u6784\\u5165\\u4f4f\\u7387(%)\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    79\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    77\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\",\n",
       "                    74\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\",\n",
       "                    70\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\",\n",
       "                    62\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\",\n",
       "                    55\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\",\n",
       "                    52\n",
       "                ],\n",
       "                [\n",
       "                    \"2017\",\n",
       "                    48\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\\uff08\\u4e07\\u4e2a\\uff09\",\n",
       "                \"\\u517b\\u8001\\u673a\\u6784\\u5165\\u4f4f\\u7387(%)\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\\uff08\\u4e07\\u4e2a\\uff09\": true,\n",
       "                \"\\u517b\\u8001\\u673a\\u6784\\u5165\\u4f4f\\u7387(%)\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2010\",\n",
       "                \"2011\",\n",
       "                \"2012\",\n",
       "                \"2013\",\n",
       "                \"2014\",\n",
       "                \"2015\",\n",
       "                \"2016\",\n",
       "                \"2017\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\\u4e0e\\u5165\\u4f4f\\u7387\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_7cb9c8ae541a47a0ac32a6c1bcdcd3cc.setOption(option_7cb9c8ae541a47a0ac32a6c1bcdcd3cc);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x27083dbca60>"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Line\n",
    "x=['2010','2011','2012','2013','2014','2015','2016','2017']\n",
    "\n",
    "y1_data=nianfen[\"养老服务机构和设施总数(万个)\"]\n",
    "y1=list(y1_data)\n",
    "\n",
    "y2_data=nianfen[\"养老机构入住率(%)\"]\n",
    "y2=list(y2_data)\n",
    "\n",
    "line=(\n",
    "    Line()\n",
    "    .add_xaxis(xaxis_data=x)\n",
    "    .add_yaxis(series_name=\"养老机构数量（万个）\",y_axis=y1,symbol=\"arrow\",is_symbol_show=True)\n",
    "    .add_yaxis(series_name=\"养老机构入住率(%)\",y_axis=y2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"养老机构数量与入住率\"))\n",
    ")\n",
    "line.render_notebook()\n",
    "# line.render('html/养老机构数量与入住率.html')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": false,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "533.6px",
    "left": "36px",
    "top": "110.8px",
    "width": "384px"
   },
   "toc_section_display": false,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
